﻿#region Usings

using System;
using System.Collections.Generic;
using System.ComponentModel.DataAnnotations;

#endregion

namespace RailNet.Dao.Entity
{
    [DisplayColumn("Code")]
    [Serializable]
    public class Ru : IEquatable<Ru>, IEntity
    {
        #region Primitive Properties

        [Key]
        public long Id { get; set; }

        [Required]
        [MaxLength(30)]
        public string Name { get; set; }

        [Required]
        [MaxLength(2)]
        public string Code { get; set; }

        [Required]
        [MaxLength(6)]
        public string CodeLong { get; set; }

        #endregion

        #region Navigation Properties

        [InverseProperty("Ru")]
        public virtual ICollection<Station> Stations { get; set; }

        [InverseProperty("Ru")]
        public virtual ICollection<RelationRu> RelationRus { get; set; }

        [InverseProperty("Ru")]
        public virtual ICollection<PriceDistance> PriceDistances { get; set; }

        [InverseProperty("Ru")]
        public virtual ICollection<PriceSerial> PriceSerials { get; set; }

        #endregion

        #region IEquatable members

        public bool Equals(Ru other)
        {
            return Id == other.Id;
        }

        public override int GetHashCode()
        {
            return (int) Id;
        }

        #endregion
    }
}